//
//  NewsViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/25.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "NewsViewModel.h"
//#import "CommonNewsFrame.h"
#import "CommonNews.h"
#import "RemindModel.h"
#import "RecommendModel.h"

@implementation NewsViewModel

-(void)getNewsDataWithDic:(NSDictionary *)dic Success:(void (^)(NSArray *))completion{
    NSString *url = [NSString stringWithFormat:@"%@%@",HOSPITAL_URL,COMMON_URL];
    [NetWorker getCommonDatasWithURLStr:url body:dic success:^(id result) {
        NSArray *arr = [JsonHelper arrayWithJsonString:result[@"Entity"]];
        NSMutableArray *newsArr = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            BSNewsModel *news ;
            if (self.type == NewsTypeCommon) {
                news = [CommonNews yy_modelWithDictionary:dic];
            }else if(self.type == NewsTypeRemind){
                news = [RemindModel yy_modelWithDictionary:dic];
            }else if (self.type == NewsTypeRecommend){
                news = [RecommendModel yy_modelWithDictionary:dic];
            }
            CommonNewsFrame *newsF = [[CommonNewsFrame alloc] init];
            newsF.news = news;
            [newsArr addObject:newsF];
        }
        completion(newsArr);
    } failure:^(id result) {
        completion([NSArray array]);
    }];

}

@end
